home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Mark Pilgrim / Ghost 1.0 / source / Prepare ƒ / MSG Shell ƒ / msg shell menus.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-30  |  2.4 KB  |  118 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        msg shell menus.c
  4.  
  5. Purpose:    This module handles menu selections.
  6.  
  7.  
  8. MSG Prepare 1.0 -- minimal integrity check preparation program
  9. Copyright (C) 1993 Mark Pilgrim
  10.  
  11. This program is free software; you can redistribute it and/or modify
  12. it under the terms of the GNU General Public License as published by
  13. the Free Software Foundation; either version 2 of the License, or
  14. (at your option) any later version.
  15.  
  16. This program is distributed in the hope that it will be useful,
  17. but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19. GNU General Public License for more details.
  20.  
  21. You should have received a copy of the GNU General Public License
  22. along with this program in a file named "GNU General Public License".
  23. If not, write to the Free Software Foundation, 675 Mass Ave,
  24. Cambridge, MA 02139, USA.
  25.  
  26. \**********************************************************************/
  27.  
  28. #include "msg menus.h"
  29. #include "MSG Prepare.h"
  30.  
  31. MenuHandle        gAppleMenu;
  32. MenuHandle        gFileMenu;
  33. MenuHandle        gEditMenu;
  34.  
  35. void AdjustMenus(void)
  36. {
  37.     WindowPeek    theWindow;
  38.     int            kind;
  39.     int            i;
  40.     
  41.     theWindow = (WindowPeek)FrontWindow();
  42.     kind = theWindow ? theWindow->windowKind : 0;
  43.     
  44.     if(kind < 0) EnableItem(gEditMenu, 0);
  45.     else DisableItem(gEditMenu, 0);
  46.     
  47.     if(theWindow)
  48.         EnableItem(gFileMenu, closeItem);
  49.     else
  50.         DisableItem(gFileMenu, closeItem);
  51.     
  52.     DrawMenuBar();
  53. }
  54.  
  55. void HandleMenu(long mSelect)
  56. {
  57.     int            menuID = HiWord(mSelect);
  58.     int            menuItem = LoWord(mSelect);
  59.     
  60.     switch (menuID)
  61.     {
  62.         case appleMenu:
  63.             HandleAppleMenu(menuItem);
  64.             break;
  65.         case fileMenu:
  66.             HandleFileMenu(menuItem);
  67.             break;    
  68.         case editMenu:
  69.             HandleEditMenu(menuItem);
  70.             break;
  71.     }
  72. }
  73.  
  74. void HandleAppleMenu(int menuItem)
  75. {
  76.     GrafPtr        savePort;
  77.     Str255        name;
  78.     
  79.     if(menuItem == 1)
  80.         Alert(aboutPrepare, 0L);
  81.     else
  82.     {
  83.         GetPort(&savePort);
  84.         GetItem(gAppleMenu, menuItem, name);
  85.         OpenDeskAcc(name);
  86.         SetPort(savePort);
  87.     }
  88. }
  89.  
  90. void HandleFileMenu(int menuItem)
  91. {
  92.     Point            where;
  93.     SFReply            reply;
  94.     
  95.     switch (menuItem)
  96.     {
  97.         case openItem:
  98.             where.h=40;
  99.             where.v=40;
  100.             SFGetFile(where,"\p",0L,-1,0L,0L,&reply);
  101.             if (reply.good)
  102.                 OpenFile(reply.fName, reply.vRefNum);
  103.             break;
  104.         case closeItem:
  105.             DisposeWindow(FrontWindow());
  106.             AdjustMenus();
  107.             break;
  108.         case quitItem:
  109.             gDone = TRUE;
  110.             break;
  111.     }
  112. }
  113.  
  114. void HandleEditMenu(int menuItem)
  115. {
  116.     SystemEdit(menuItem - 1);
  117. }
  118.